﻿using System;

namespace sharpxbot.Core.Security.Traffic
{
    public class DateValidator
    {
        public void ValidateHour(int hour)
        {
            if (hour < Constants.MinHour || hour > Constants.MaxHour)
                throw new ArgumentException(String.Format("Illegal hour. Must be from [{0}..{1}]", Constants.MinHour, Constants.MaxHour));
        }

        public void ValidateDay(int day)
        {
            if (day < Constants.MinDay || day > Constants.MaxDay)
                throw new ArgumentException(String.Format("Illegal day. Must be from [{0}..{1}]", Constants.MinDay, Constants.MaxDay));
        }

        public void ValidateMonth(int month)
        {
            if (month < Constants.MinMonth || month > Constants.MaxMonth)
                throw new ArgumentException(String.Format("Illegal month. Must be from [{0}..{1}]", Constants.MinMonth, Constants.MaxMonth));
        }

        public void ValidateYear(int year)
        {
            if (year < 0)
                throw new ArgumentException("Illegal negative year");
        }

        public void Validate(int year, int month, int day, int hour)
        {
            ValidateYear(year);
            ValidateMonth(month);
            ValidateDay(day);
            ValidateHour(hour);
        }
    }
}
